﻿namespace HuwmanCode.Net

open System
open System.IO
open System.Text

[<AutoOpen>]
module TypeExtensions =
    type System.String with
        member x.ToAsciiBytes() =
            ASCIIEncoding.ASCII.GetBytes(x)

    and System.Net.Sockets.TcpListener with
        member x.AcceptTcpClientAsync() =
            Async.FromBeginEnd(x.BeginAcceptTcpClient, x.EndAcceptTcpClient)

    and System.Net.Sockets.NetworkStream with
        member x.Write(buffer:byte array) =
            x.Write(buffer, 0, buffer.Length)

        member x.WriteAscii(text:string) =
            x.Write(text.ToAsciiBytes(), 0, text.Length)